package com.magicsoft.weitown.ui;

import android.app.Dialog;
import android.content.Context;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.Window;
import android.view.WindowManager;

import com.boyuan.huijiaoyu.R;

/**
 * @author liqingjun
 *
 */
public class CustomDownloadDialog extends Dialog {

	
	Context context;
	 
	 public CustomDownloadDialog(Context context, int theme){
	        super(context, theme);
	        this.context = context;
	    }
	    @Override
	    protected void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        this.setContentView(R.layout.custom_download_dialog);
	        
	        
	        //set window params
	         Window window = getWindow();
	         window.setBackgroundDrawableResource(R.color.transparent);
	         WindowManager.LayoutParams params = window.getAttributes();
	         int density = getWidthPixels(context);
	         params.width = density-40;
	         params.gravity = Gravity.CENTER;
	         window.setAttributes(params);
	        
	         this.setCanceledOnTouchOutside(false);
	    }
	    
	    
	    private int getWidthPixels(Context context) {
	         Resources resources = context.getResources();
	         DisplayMetrics dm = resources.getDisplayMetrics();
	        return dm.widthPixels;
	        //return dm.density;
	     }

}
